﻿
#Import-Module WebAdministration

$pool = "IIS:\AppPools\"
$site =  "IIS:\Sites\"
$app = "vip_glz_yaya"
$web = "vip_glz_haha"
$physical = "F:\DATAWEB\GateWay"
$binding = ":8810:"

$path = $pool + $app

$ext = Test-Path $path
if($ext -eq $false)
{
    New-Item $path
    Set-ItemProperty $path managedRuntimeVersion ''
    Set-ItemProperty $path managedPipelineMode 1
    Set-ItemProperty $path startMode AlwaysRunning
}else
{
    Write-Host "pool exist"
}

$webpath = $site + $web

$webext = Test-Path $webpath
if($webext -eq $false)
{
    New-Item $webpath -bindings @{protocol="http";bindingInformation= $binding} -physicalPath $physical
    
    Set-ItemProperty $webpath -Name applicationPool -Value $app

    New-WebBinding -Name $web -Protocol "http" -IPAddress "*" -Port 80 -HostHeader glz.com.hk
}else
{
    Write-Host "web exist"
}